<template>
  <el-row class="tables">
    <!-- 表格 头部 -->
    <el-row class="tableTh">
      <el-col :span="5">
        <span>点检编号</span>
      </el-col>
      <el-col :span="4">
        <span>设备名称</span>
      </el-col>
      <el-col :span="4">
        <span>点检标准</span>
      </el-col>
      <el-col :span="3">
        <span>点检日期</span>
      </el-col>
      <el-col :span="4">
        <span>作业人</span>
      </el-col>
      <el-col :span="4">
        <span>点检状态</span>
      </el-col>
    </el-row>
    <!-- 表格行 -->
    <div v-if="tableData.length > 0" class="showDiv">
      <el-row v-for="item in tableData" :key="item.id" class="tableTd">
        <el-col :span="5">
          <span>{{ item.pointNo }}</span>
        </el-col>
        <el-col :span="4">
          <span>{{ item.equipName }}</span>
        </el-col>
        <el-col :span="4">
          <span>{{ item.equipName }}</span>
        </el-col>
        <el-col :span="3">
          <span>{{ item.checkTime }}</span>
        </el-col>
        <el-col :span="4">
          <span>{{ item.checkName }}</span>
        </el-col>
        <el-col :span="4">
          <span>{{ item.result === 1 ? '通过':'不通过' }}</span>
        </el-col>
      </el-row>
    </div>
    <div v-else class="kong">暂无数据</div>
  </el-row>
</template>
<script>
export default {
  props: {
    // numObj: {
    //   type: Object,
    //   default: {}
    // }
  },
  data() {
    return {
      search: {
        current: 1,
        size: 5
      },
      total: 0,
      tableData: [],
      countDown: 20,
      timeInterval: () => {},
      tableInterval: () => {}
    }
  },
  watch: {},
  beforeDestroy() {
    clearInterval(this.timeInterval)
    clearInterval(this.tableInterval)
  },
  mounted() {
    this.startInterval()
  },
  methods: {
    async getTableInfo() {
      /* 获取表格数据 */
      const res = await this.$axios.get(
        '/board/equip/pointMaintain/pointRecord'
      )
      if (res?.data.code === 200) {
        this.tableData = res.data.data
      }
    },
    async startInterval() {
      /** 开启时间定时器 */
      let countDown = 20
      this.timeInterval = setInterval(() => {
        // this.time = getCurrentDate()
        countDown--
        if (countDown === 0) {
          countDown = 20
        }
        this.countDown = countDown
      }, 1000)
      /** 开启表格刷新定时器 */
      this.tableInterval = setInterval(() => {
        if (this.search.current * this.search.size >= this.total) {
          this.search.current = 1
        } else {
          this.search.current++
        }
        this.getTableInfo()
      }, 30 * 1000)
    }
  }
}
</script>
<style lang='scss' scoped>
.red {
  color: red;
}
.tables {
  height: 100%;
  padding-top: 10px;
  color: #fff;
  .showDiv {
    height: 80%;
  }
  .tableTh,
  .tableTd {
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    .el-col {
      text-overflow: ellipsis; /*让截断的文字显示为点点。还有一个值是clip意截断不显示点点*/
      white-space: nowrap; /*让文字不换行*/
      overflow: hidden; /*超出要隐藏*/
    }
  }
  .tableTh {
    height: 20%;
    font-weight: normal;
    font-size: 16px;
    color: #62e0ff;
    background: rgb(0, 195, 244, 0.3);
  }
  .tableTd {
    height: 20%;
    font-size: 14px;
    color: #f5f5f5;
  }
  .kong {
    height: calc(100% - 65px);
  }
}
</style>
